package com.example.practicedemo.mapper;

import com.example.practicedemo.dto.UserDto;
import com.example.practicedemo.pojo.User;
import com.example.practicedemo.pojo.Work;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

@Mapper(componentModel = "spring")
public interface UserMapper {
    @Mappings({
            @Mapping(source = "name", target = "nameJson"),
            @Mapping(source = "age", target = "ageJson"),
            @Mapping(source = "dataTime", target = "dataTimeJson"),
            @Mapping(source = "money", target = "moneyJson")
    })
    UserDto userConvert(User user);

    @Mappings({
            @Mapping(source = "user.name", target = "nameJson"),
            @Mapping(source = "user.age", target = "ageJson"),
            @Mapping(source = "user.dataTime", target = "dataTimeJson"),
            @Mapping(source = "user.money", target = "moneyJson"),
            @Mapping(source = "work.name", target = "workName"),
            @Mapping(source = "user.address", target = "userAddress"),
            @Mapping(source = "work.address", target = "workAddress"),
    })
    UserDto userWorkToDto(User user, Work work);
}
